import { defineStore } from "pinia";

interface nickNameModel{
  nickName:undefined|string,
  isLogin:boolean
}

export const loginStatus = defineStore({
  id:'loginStatus',
  state:():nickNameModel=>({
    nickName:undefined,
    isLogin:false
  }),
  getters:{
    getNickName():undefined|string{
      return this.nickName;
    },
    getIsLogin():boolean{
      return this.isLogin;
    }
  },
  actions:{
    login(){
      this.nickName = localStorage.getItem("nickName") as string
      this.isLogin = true
    },
    outlogin(){
      this.nickName = undefined
      this.isLogin = false
    }
  }
})